<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="/classteacher/js/jquery-3.5.0.js"></script>
    <link rel="stylesheet" type="text/css" href="bootstrap/bootstrap.min.css">
    <script src="/classteacher/Vue/Vue.js"></script>
    <script src="/classteacher/Vue/axios.js"></script>
    <script src="layui/layer/layer.js"></script>
</head>
<body>

    <div id="app" class="container">
        <div>
            <button class="btn btn-info" @click="update()"/>更新差生池
            <button class="btn btn-info" @click="bad()"/>查询差生池
        </div>
        <div  v-for="(value, key) in clazz">
            <label>{{key}}：</label>
            <table class="table table-light table-bordered table-hover">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>生日</th>
                        <th>电话</th>
                        <th>邮箱</th>
                        <th>账号</th>
                        <th>操作</th>
                    </tr>
                </thead>

                <tbody>
                    <tr v-for="stu in value">
                        <td>{{stu.stuid}}</td>
                        <td>{{stu.sname}}</td>
                        <td>{{stu.gender}}</td>
                        <td>{{stu.birthday}}</td>
                        <td>{{stu.phone}}</td>
                        <td>{{stu.email}}</td>
                        <td>{{stu.account}}</td>
                        <td><button class="btn btn-info" @click="find(stu.stuid)"/>查看差生成绩</td>
                    </tr>
                </tbody>

                <tfoot>
                </tfoot>
            </table>
        </div>

    </div>
    <script>
        //差生池  李英勇
        let refreshToken = localStorage.getItem("refreshToken");
        let token=localStorage.getItem("token");
        new Vue({
            el:"#app",
            data:{
                clazz:{}
            },
            methods:{
                //更新差生池
                update:function(){
                    axios.get("addPool",{
                        headers:{
                            "token":token,
                            "refreshToken":refreshToken
                        }
                    }).then(res=>{
                        if(res.data.code==0){
                            layer.msg(res.data.msg);
                            if(res.headers.token!=null){
                                //更新本地token
                                localStorage.setItem("token",res.headers.token);
                            }
                        }

                    });
                },
                //获取差生池
                bad:function(){
                    axios.get("findBadStu",{
                        headers:{
                            "token":token,
                            "refreshToken":refreshToken
                        }
                    }).then(res=>{
                        console.log(res.data.data);
                        if(res.data.code==0){
                            this.clazz=res.data.data;
                            if(res.headers.token!=null){
                                //更新本地token
                                localStorage.setItem("token",res.headers.token);
                            }
                        }

                    });
                },
                //查看差生的试卷
                find:function(sid){
                    console.log(sid);
                    localStorage.setItem("sid",sid);
                    layer.open({
                        type: 2,
                        title: "试卷页",
                        maxmin: true,
                        skin: 'layui-layer-rim', //加上边框
                        area: ['1000px', '550px'], //宽高
                        content: 'testPaper.html'

                    });

                }
            },
            mounted(){
            }
        });
    </script>
</body>
</html>